package twentytwentyone_3;

/**
 * @Author: Zahi
 * @Description:
 * @Date Created in 2021-03-23 17:32
 * @Modified By:
 */
public class JudgeCircle_657 {
    public static void main(String[] args){

    }

    public static boolean judgeCircle(String moves){
        int u = countSteps(moves, 'U');
        int d = countSteps(moves, 'D');
        int l = countSteps(moves, 'L');
        int f = countSteps(moves, 'F');
        return u == d && l == f;
    }

    public static int countSteps(String moves,char step){
        int count = 0;
        char[] chars = moves.toCharArray();
        for (char aChar : chars) {
            if (aChar == step){
                count++;
            }
        }
        return count;
    }
}
